﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Threading;
using KOF.ViewModels.Commands;
using KOF.Helpers;
using Newtonsoft.Json;
using System.IO.IsolatedStorage;
using System.Collections.Generic;

namespace KOF.ViewModels
{
    public class ShoeDetailsViewModel1 : ViewModelBase
    {
         public ShoeDetailsViewModel1()
        {
            getFavoriteList();
        }

         private System.Collections.ObjectModel.ObservableCollection<ReleaseResult> _listItemSource;
         public System.Collections.ObjectModel.ObservableCollection<ReleaseResult> ListItemSource
         {
             get
             {
                 return _listItemSource;
             }
             set
             {
                 if (_listItemSource != value)
                 {
                     _listItemSource = value;
                 }
                 OnPropertyChanged("ListItemSource");
             }
         }

         public void getFavoriteList()
         {
             if (IsolatedStorageSettings.ApplicationSettings.Contains("FavoritesList"))
             {
                 List<KOF.Helpers.ReleaseResult> lstFav = (List<KOF.Helpers.ReleaseResult>)IsolatedStorageSettings.ApplicationSettings["FavoritesList"];

                 if (lstFav != null)
                 {
                     if (ListItemSource == null) ListItemSource = new System.Collections.ObjectModel.ObservableCollection<ReleaseResult>();
                     foreach (ReleaseResult item in lstFav)
                     {
                        
                         //if (item.title.Length > 28)
                         //{
                         //    item.title = item.title.Substring(0, 24) + "...";
                         //}
                         //if (item.style.Length > 28)
                         //{
                         //    item.style = item.style.Substring(0, 24) + "...";
                         //}
                         (App.Current as App).lstReleaseResult.Add(item);
                         ListItemSource.Add(item);
                     }
                 }
             }
         }


    }
}
